Skip to content

Conversation

@bakert-96
Copy link

Description

Updates to the validation of time field and categorical field to query all remote clusters when a wildcard cluster prefix is specified.

Related Issues

This is related to the proposal opened here #1606

Check List

  • Commits are signed per the DCO using --signoff.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

… detection jobs

- Updated time field and category field validation methods to query all remote indices when wildcard specified for cluster name
- Added @Inject annotation for TransportService in multiple action handlers
Signed-off-by: Tim Baker <[email protected]>
@bakert-96 bakert-96 force-pushed the feature/support-cluster-wildcard branch from 4aa1195 to 34445ef Compare November 12, 2025 17:50
@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

❌ Patch coverage is 27.63158% with 55 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.07%. Comparing base (a6c1916) to head (34445ef).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../rest/handler/AbstractTimeSeriesActionHandler.java 26.66% 49 Missing and 6 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1612      +/-   ##
============================================
- Coverage     81.31%   81.07%   -0.25%     
+ Complexity     6144     6139       -5     
============================================
  Files           542      542              
  Lines         24998    25065      +67     
  Branches       2543     2557      +14     
============================================
- Hits          20328    20321       -7     
- Misses         3394     3461      +67     
- Partials       1276     1283       +7     
Flag Coverage Δ
plugin 81.07% <27.63%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../handler/ValidateAnomalyDetectorActionHandler.java 100.00% <ø> (ø)
...nsport/ValidateAnomalyDetectorTransportAction.java 100.00% <ø> (ø)
.../rest/handler/ValidateForecasterActionHandler.java 100.00% <ø> (ø)
...t/transport/ValidateForecasterTransportAction.java 100.00% <ø> (ø)
...ies/transport/BaseDeleteConfigTransportAction.java 82.88% <ø> (ø)
...es/transport/BaseEntityProfileTransportAction.java 77.58% <ø> (ø)
...series/transport/BaseGetConfigTransportAction.java 86.17% <ø> (ø)
...h/timeseries/transport/BaseJobTransportAction.java 88.09% <ø> (ø)
...s/transport/BaseValidateConfigTransportAction.java 73.11% <100.00%> (+0.29%) ⬆️
...ensearch/timeseries/transport/ResultProcessor.java 83.95% <ø> (+0.80%) ⬆️
... and 1 more

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bakert-96
Copy link
Author

I will get a changelog item and tests added 👌


protected void validateTimeField(boolean indexingDryRun, ActionListener<T> listener) {
protected void validateTimeFieldInAllClusters(boolean indexingDryRun, ActionListener<T> listener) {
List<String> wildcardClusterIndices = config.getIndices().stream().filter(idx -> idx.startsWith("*:")).toList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's duplicate code in validateTimeFieldInAllClusters and validateCategoricalFieldsInAllClusters, I suggest we extract to a method to handle some of this validation, if you want to have different validation issue types you can pass that in as variables.

for (String remote : remoteClusters) {
List<String> remoteIndices = wildcardClusterIndices
.stream()
.map(idx -> idx.substring(2)) // remove "*:" prefix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
here if a user passes this to indices:
"indices": [ "*:" ],
then we have empty indices being passed, we can probably filter or validate earlier here so error message makes more sense then: Exceptions: [Fail to get the index mapping of []

import org.opensearch.timeseries.util.RestHandlerUtils;
import org.opensearch.timeseries.util.SecurityClientUtil;
import org.opensearch.transport.TransportService;
import org.opensearch.transport.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expand wildcard imports here, we try to have all imports be specific (for example:

import org.opensearch.timeseries.util.ParseUtils;
import org.opensearch.timeseries.util.RestHandlerUtils;
import org.opensearch.timeseries.util.SecurityClientUtil;

listener
.onFailure(
new ValidationException(
"No indices specified for time field validation.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently i know that we are inside time field validation but for this error specifically its more so that no indices are specific for the given configuration, this can be put as a ValidationIssueType.INDICES as the error here isn't necessarily for time field. Same comment can be made on similar code in checking of categorical field. if we move the code to a different method we can relook at the error messages we have.

@amitgalitz
Copy link
Member

Thank you for making this change!
Added some comments on first review, try to add some UT/IT for the change. Additionally one more improvement that can be made here or in future PRs is that we can have the cluster wildcard support prefix, so we can look for something like cluster*, right now it would look for cluster with the name cluster* but we can expand that to all clusters under that pattern like cluster1, cluster200 and etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants